/**
 * @param {number} x
 * @param {number} target
 * @return {number}
 */
 var leastOpsExpressTarget = function(x, target) {
    let xAdd = x
    let n = 1
    let numOperator = 0
    while (xAdd < target){
        xAdd *= x
        n++
    }
    numOperator = n
    console.log(xAdd)
    if(xAdd/2 > target){
        xAdd = Math.pow(x,n-1)
        console.log(xAdd)
        // while (xAdd < target){

        // }
    }
    console.log(222)
    // if(xAdd-target>=Math.pow(x,n-1)){
    //     xAdd = xAdd-target - Math.pow(x,n-1)
    //     numOperator++
    // }
    // console.log(xAdd,Math.pow(x,n-1),numOperator)
};
leastOpsExpressTarget(3,19)